import 'package:app/core/net/config/global.dart';
import 'package:logger/logger.dart';
import 'package:sprintf/sprintf.dart';

class LogPrint {
  static LogPrint _instance;

  // static LogPrint get instance {
  //   return getInstance();
  // }

  static Logger _logger;

  LogPrint._();

  _init() {
    _logger = Logger();
  }

  static LogPrint getInstance() {
    if (_instance == null) {
      _instance = LogPrint._();
      _instance._init();
    }
    return _instance;
  }

  printInfo(String v) {
    if (Global.isDebug) {
      _logger.i(sprintf("%s\n%s", [_getCurrentTime(), v]));
    }
  }

  printDebug(String d) {
    if (Global.isDebug) {
      _logger.d(sprintf("%s\n%s", [_getCurrentTime(), d]));
    }
  }

  printError(String e) {
    if (Global.isDebug) {
      _logger.e(sprintf("%s\n%s", [_getCurrentTime(), e]));
    }
  }

  String _getCurrentTime() {
    return DateTime.now().toString();
  }
}
